import java.awt.*;
import java.awt.event.TextEvent;
import java.awt.event.TextListener;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-11-16  09:21
 */
public class TexEvent extends Frame implements TextListener {
    static TexEvent frm = new TexEvent();
    static TextField txt1,txt2;

    public static void main(String[] args) {
        frm.setTitle("TextEvent");
        frm.setSize(240,160);
        txt1 = new TextField(20);
        txt2 = new TextField(20);
        txt1.addTextListener(frm);
        frm.add(txt1);
        txt2.setEditable(false);
        frm.add(txt1);
        frm.add(txt2);
        frm.setVisible(true);
    }
    @Override
    public void textValueChanged(TextEvent e) {
        txt2.setText(txt1.getText());
    }
}
